/**
 * get all method data else GET
 * @param {object} request
 * @param {Function} callback
 */
function getData(request, callback) {
  let chunks = [];
  let size = 0;
  request.on('data',(chunk)=>{
    chunks.push(chunk);
    size+=chunk.length;
  });
  request.on('end',()=>{
    if(chunks.length !== 0){
      let buffer = Buffer.concat(chunks,size);
      let string = buffer.toString();
      callback(string);
    }else{
      callback(null);
    }
  })
}

module.exports=getData;